/**
 * @author liuyong
 * @since 2021-08-02 11:41:35
 */
layui.define(['form', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var layedit = layui.layedit;
    var laydate = layui.laydate;
    form.render(null, "zmn-form");

    // 提交
    form.on('submit(zmn-form-submit)', function (obj) {
        var data = obj.field;
        var url = "/ding/group/robot/addEdit.action";

        $("#zmn-form-submit").attr("disabled", true);
        $.ajax({
            async: false,
            type: "POST",
            url: url,
            contentType: "application/json", dataType: "json", data: JSON.stringify(data),
            beforeSend: function () {
                index = layer.load(1, {
                    shade: [0.5, '#DBDBDB']
                });
            },
            success: function (json) {
                layer.close(index);
                if (json.status == 200) {
                    layer.msg(json.message, {time: 1000}, () => {
                        //location.reload();
                        parent.closeWin(true);
                    });
                } else {
                    $("#zmn-form-submit").attr("disabled", false);
                    layer.msg(json.message, {icon: 2});
                }

            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $("#zmn-form-submit").attr("disabled", false);
                layer.close(index);
            }
        })
        return false;
    });


    //对外暴露的接口
    exports('brs_ding_group_robot_detail', {});
});